package com.hejing.cloud.apis;

import cn.hutool.core.util.IdUtil;
import com.hejing.cloud.entities.PayDTO;
import com.hejing.cloud.resp.ResultData;
import org.springframework.beans.BeanUtils;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * ClassName: PayFeignApi
 * Package: com.hejing.cloud.apis
 * Description:
 *
 * @Author: HeJing
 * @Create: 2024-08-04 8:31
 * @Version: 1.0
 */
// @FeignClient(value = "cloud-payment-service")
@FeignClient(value = "cloud-gateway")
public interface PayFeignApi {

    /**
     * 新增一条流水记录
     * @param payDTO
     * @return
     */
    @PostMapping(value = "/pay/add")
    ResultData addPay(@RequestBody PayDTO payDTO);

    /**
     * 根据id删除记录流水
     * @param id
     * @return
     */
    @DeleteMapping("/pay/del/{id}")
    ResultData deletePay(@PathVariable("id") Integer id);

    /**
     * 修改记录流水
     * @param payDTO
     * @return
     */
    @PutMapping("pay/update")
    ResultData updatePay(@RequestBody PayDTO payDTO);

    /**
     * 按照主键记录查询支付流水信息
     * @param id
     * @return
     */
    @GetMapping("/pay/get/{id}")
    ResultData getPayInfo(@PathVariable("id") Integer id);

    /**
     * 查询所有流水记录
     * @return
     */
    @GetMapping("pay/get")
    ResultData getAll();

    /**
     * openfeign天然支持负载均衡
     * @return
     */
    @GetMapping(value = "/pay/get/info")
    String mylb();


    /**
     * Resilience4j CircuitBreaker 的例子
     * @param id
     * @return
     */
    @GetMapping(value = "/pay/circuit/{id}")
    public String myCircuit(@PathVariable("id") Integer id);

    /**
     * Resilience4j BulkHead的例子
     * @param id
     * @return
     */
    @GetMapping(value = "/pay/bulkhead/{id}")
    String myBulkhead(@PathVariable("id") Integer id);

    //=========Resilience4j ratelimit 的例子
    @GetMapping(value = "/pay/ratelimit/{id}")
    String myRatelimit(@PathVariable("id") Integer id);


    /**
     * Micrometer(Sleuth)进行链路监控的例子
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/pay/micrometer/{id}")
    String myMicrometer(@PathVariable("id") Integer id);

    /**
     * GateWay进行网关测试案例01
     * @param id
     * @return
     */
    @GetMapping(value = "/pay/gateway/get/{id}")
    ResultData getById(@PathVariable("id") Integer id);

    /**
     * GateWay进行网关测试案例02
     * @return
     */
    @GetMapping(value = "/pay/gateway/info")
    ResultData<String> getGatewayInfo();
}
























